//
//  UIViewController+BIDExtendViewController.m
//  HJGJCommunity
//
//  Created by mal on 2017/5/16.
//  Copyright © 2017年 mal. All rights reserved.
//

#import "UIViewController+BIDExtendViewController.h"

@implementation UIViewController (BIDExtendViewController)

- (void)showAlertView:(NSString *)msg buttonTitle:(NSString *)title tag:(id)obj functionName:(NSString *)functionName
{
    UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"提示"
                                                                   message:msg
                                                            preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:title style:UIAlertActionStyleDefault
                                                          handler:^(UIAlertAction * action) {
                                                              SEL desSelector  = NSSelectorFromString(functionName);
                                                              if([self respondsToSelector:desSelector])
                                                              {
                                                                  IMP imp = [self methodForSelector:desSelector];
                                                                  void (*func)(id, SEL, id) = (void *)imp;
                                                                  func(self, desSelector, obj);
                                                              }
                                                          }];
    
    [alert addAction:defaultAction];
    [self presentViewController:alert animated:YES completion:nil];
}

@end
